<template>
  <div id="homeview">
    <div id="homeDiv" v-if="active === 0">
      <HomeIndex></HomeIndex>
    </div>
    <van-tabbar v-model="active" @change="change" fixed>
      <van-tabbar-item icon="wap-home-o" info="3">
        <!-- <router-link to="/homeIndex">首页</router-link> -->
        首页
      </van-tabbar-item>
      <van-tabbar-item icon="search">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import HomeIndex from "@/components/HomeIndex.vue";
export default {
  components: { HomeIndex },
  data() {
    return {
      active: 0,
    };
  },
  // 刷新页面的时候自动执行获取存储在localStorage的值
  created() {
    this.active = JSON.parse(localStorage.getItem("active"));
  },
  methods: {
    change(e) {
      localStorage.setItem("active", e);
    },
  },
};
</script>
<style></style>
